package org.example.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.example.model.Features;
import org.example.model.Food;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface FoodDao {

    List<Food> getFoodList(@Param(("Food"))Food food);
    List<Features>foodFeatures();

    @Select("SELECT f.name,ff.featuresId  FROM features f RIGHT JOIN food_features ff ON f.id = ff.featuresId")
    List<Features> foodFeatures2();


    void addFood(Food food);


    Food getFoodId(String name);

    @Insert("INSERT INTO food_features(foodId,featuresId)  VALUES (#{foodId},#{featuresId})")
    void addFoodFeatures(@Param("featuresId") Integer featuresId,@Param("foodId") int foodId);

    @Delete("DELETE FROM food WHERE id = #{id}")
    int deleteFood(@Param("id") int id);

    @Delete("DELETE FROM food_features WHERE foodId = #{id}")
    void deleteFoodFeatures(@Param("id") int id);
}
